from pyqt import *
base_url = 'http://127.0.0.1:3003/#/'
import socket
def __get_url(url):
    return base_url + url

def __check_ip(url):
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    result = sock.connect_ex(('127.0.0.1', 3003))
    if result == 0:
        print(
            "Port is open")
    else:
        print(
            "Port is not open")
        from subprocess import run
        run("start npm start", shell=True)
        time.sleep(25)
        print("Please waiting for 25 seconds...")

    app = QApplication(sys.argv)
    win = MainWindow(__get_url(url))
    win.show()
    app.exit(app.exec_())

def main():
    __check_ip('')

def loop_if_else():
    __check_ip('LoopIfElse')

def force_enum():
    __check_ip('ForceEnum')

def greedy():
    __check_ip('Greedy')

def recursion():
    __check_ip('Recursion')

def dynamic():
    __check_ip('Dynamic')

def search():
    __check_ip('search')

def sort():
    __check_ip('sort')